﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EPiServer.Core;
using EPiServer.Web.PropertyControls;
using EPiServer.Web.WebControls;

namespace TemplateFoundation.UI.WebControls
{
    /// <summary>
    /// Used to add a page link selector when creating user interfaces for the EPiServer UI
    /// </summary>
    public class PageSelector : PagePropertyStyleControlBase
    {
        private readonly InputPageReference _control = new InputPageReference();

        /// <summary>
        /// Creates a page selector with standard name and description
        /// </summary>
        public PageSelector()
        {
            Name = "Page link";
            Description = "Select a page on the website";
        }

        /// <summary>
        /// Used to create the control to render as a property control
        /// </summary>
        /// <returns></returns>
        public override System.Web.UI.Control CreatePropertyControl()
        {

            return _control;
        }
        
        /// <summary>
        /// The page selected with the control
        /// </summary>
        public PageReference SelectedPage
        {
            get
            {
                return _control.PageLink;
            }
            set
            {
                _control.PageLink = value;
            }
        }
    }
}
